package pkmn.attributes;

public class BattleAttributes{

    private int attack;
    private int defense;
    private int spAttack;
    private int spDefense;
    private int speed;
    private int accuracy;
    private int evasion;

    public BattleAttributes(){
        this.attack = 0;
        this.defense = 0;
        this.spAttack = 0;
        this.spDefense = 0;
        this.speed = 0;
        this.accuracy = 0;
        this.evasion = 0;
    }

    public boolean incAttack(){
        if (this.attack >= 6){
            this.attack = 6;
            return false;
        }
        this.attack++;
        return true;
    }

    public boolean incDefense(){
        if (this.defense >= 6){
            this.defense = 6;
            return false;
        }
        this.defense++;
        return true;
    }

    public boolean incSpAttack(){
        if (this.spAttack >= 6){
            this.spAttack = 6;
            return false;
        }
        this.spAttack++;
        return true;
    }

    public boolean incSpDefense(){
        if (this.spDefense >= 6){
            this.spDefense = 6;
            return false;
        }
        this.spDefense++;
        return true;
    }

    public boolean incSpeed(){
        if (this.speed >= 6){
            this.speed = 6;
            return false;
        }
        this.speed++;
        return true;
    }

    public boolean incAccuracy(){
        if (this.accuracy >= 6){
            this.accuracy = 6;
            return false;
        }
        this.accuracy++;
        return true;
    }

    public boolean incEvasion(){
        if (this.evasion >= 6){
            this.evasion = 6;
            return false;
        }
        this.evasion++;
        return true;
    }

    public boolean decAttack(){
        if (this.attack <= -6){
            this.attack = -6;
            return false;
        }
        this.attack--;
        return true;
    }

    public boolean decDefense(){
        if (this.defense <= -6){
            this.defense = -6;
            return false;
        }
        this.defense--;
        return true;
    }

    public boolean decSpAttack(){
        if (this.spAttack <= -6){
            this.spAttack = -6;
            return false;
        }
        this.spAttack--;
        return true;
    }

    public boolean decSpDefense(){
        if (this.spDefense <= -6){
            this.spDefense = -6;
            return false;
        }
        this.spDefense--;
        return true;
    }

    public boolean decSpeed(){
        if (this.speed <= -6){
            this.speed = -6;
            return false;
        }
        this.speed--;
        return true;
    }

    public boolean decAccuracy(){
        if (this.accuracy <= -6){
            this.accuracy = -6;
            return false;
        }
        this.accuracy--;
        return true;
    }

    public boolean decEvasion(){
        if (this.evasion <= -6){
            this.evasion = -6;
            return false;
        }
        this.evasion--;
        return true;
    }

    private double factor(int level){
        double ret = 1.0;
        if (level == -6)
            ret = 0.25;
        else if (level == -5)
            ret = 0.29;
        else if (level == -4)
            ret = 0.33;
        else if (level == -3)
            ret = 0.4;
        else if (level == -2)
            ret = 0.5;
        else if (level == -1)
            ret = 0.66;
        else if (level == 0)
            ret = 1.0;
        else if (level == 1)
            ret = 1.5;
        else if (level == 2)
            ret = 2.0;
        else if (level == 3)
            ret = 2.5;
        else if (level == 4)
            ret = 3.0;
        else if (level == 5)
            ret = 3.5;
        else if (level == 6)
            ret = 4.0;

        return ret;
    }

    public double getAttack(){
        return factor(this.attack);
    }

    public double getDefense(){
        return factor(this.defense);
    }

    public double getSpAttack(){
        return factor(this.spAttack);
    }

    public double getSpDefense(){
        return factor(this.spDefense);
    }

    public double getSpeed(){
        return factor(this.speed);
    }

    public double getAccuracy(){
        return factor(this.accuracy);
    }

    public double getEvasion(){
        return factor(this.evasion);
    }

    @Override
    public String toString() {
        return "-Attack: " + this.attack
               + "\n-Deffense: " + this.defense
               + "\n-Sp. Attack: " + this.spAttack
               + "\n-Sp. Deffense: " + this.spDefense
               + "\n-Speed: " + this.speed;
    }
}
